// src/stores/layoutStore.js
import { defineStore } from 'pinia';
import { ref, computed } from 'vue'; // 导入 computed
import { ArrowLeft, ArrowRight } from '@element-plus/icons-vue'; // 导入图标

export const useLayoutStore = defineStore('layout', () => {
    // State
    const isSidebarCollapsed = ref(false);

    // Getter (计算属性)
    const toggleIcon = computed(() =>
        isSidebarCollapsed.value ? ArrowRight : ArrowLeft
    );

    // Action
    const toggleSidebar = () => {
        isSidebarCollapsed.value = !isSidebarCollapsed.value;
    };

    return {
        isSidebarCollapsed,
        toggleSidebar,
        toggleIcon // 【关键】将 toggleIcon 也导出
    };
});